--
-- Author: ping.wang
-- Date: 2019-05-15 12:35:09
--
-- DailyworkflowController
--

local DailyworkflowView = import("..views.DailyworkflowView")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ControllerBase)

function ClassRef:ctor(data)
    self.super.ctor(self, data)
end

function ClassRef:init()
    self._model = app:getInst("DailyworkflowModel")
end

function ClassRef:removeListeners()
    self.super.removeListeners(self)
end

function ClassRef:onEvent(eventName, data)
end

function ClassRef:listEvent()
    return {}
end


function ClassRef:openView(data)
    if nil == self._view then
        self._view = DailyworkflowView.new(app.mvc.VIEWTYPE_BLUR, {selectedIdx = data, operate = handler(self, self.onOperate)})
        self._view:onCloseView(handler(self, self.closeView))
        self._view:onClearView(handler(self, self.clearView))
        self._view:onOperate(handler(self, self.onOperate))
    end
    self:addChild(self._view, data)

    self._view:show()
end
function ClassRef:clearView()
    if self._view then
        self._view = nil
    end
end

-------------------------------------------------------


-------------------------------------------------------
function ClassRef:onOperate(op, data)
    print("DailyworkflowController:onOperate op = " .. op)
    if op == "getTimelineDataFromServer" then
        --self._model:reqDailyTimelineInfo()
    elseif op == "getDailyRoutine" then
        self._model:reqDailyRoutineInfo()
    elseif op == "getWeekRoutine" then
        self._model:reqWeekRoutineInfo()
    end
end

function ClassRef:refreshDailyTimelinePanel(data)
    if cc.isAlive(self._view) then
        self._view:refreshTimelinePanel(data)
    end
end

return ClassRef
